package ch.trainingtest.beans;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;

import ch.trainingtest.dao.UserDao;
import ch.trainingtest.entity.User;

@Singleton
@Startup
public class UserBeanSingleton {

	@EJB
	private UserDao userDao;
	
	@PostConstruct
	public void createUsers() {
		User userPaul = new User();
		userPaul.setUsername("paul");
		userPaul.setPassword("paul");
		userDao.persist(userPaul);
		User userBarbara = new User();
		userBarbara.setUsername("barbara");
		userBarbara.setPassword("barbara");
		userDao.persist(userBarbara);
		User userLuisa = new User();
		userLuisa.setUsername("luisa");
		userLuisa.setPassword("luisa");
		userDao.persist(userLuisa);
		User userDavid = new User();
		userDavid.setUsername("david");
		userDavid.setPassword("david");
		userDao.persist(userDavid);
	}
}
